﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Hotnet.Biz.NSBizPicture;
using Hotnet.Entity.Enum;
using Hotnet.Biz.NSBizMusic;
using Hotnet.Biz.NSBizVideo;
using Hotnet.Biz.NSBizNews;
using Hotnet.Web.Utility;

namespace Hotnet.Web.Filters
{
	public class FrontFilterAttribute : ActionFilterAttribute
	{
		private BizPictureCategory bizPictureCategory;
		private BizPictureCategory BizPictureCategory
		{
			get
			{
				if (bizPictureCategory == null)
				{
					bizPictureCategory = new BizPictureCategory();
				}
				return bizPictureCategory;
			}
		}

		private BizMusicCategory bizMusicCategory;
		private BizMusicCategory BizMusicCategory
		{
			get
			{
				if (bizMusicCategory == null)
				{
					bizMusicCategory = new BizMusicCategory();
				}
				return bizMusicCategory;
			}
		}

		private BizVideoCategory bizVideoCategory;
		private BizVideoCategory BizVideoCategory
		{
			get
			{
				if (bizVideoCategory == null)
				{
					bizVideoCategory = new BizVideoCategory();
				}
				return bizVideoCategory;
			}
		}

		private BizNewsCategory bizNewsCategory;
		private BizNewsCategory BizNewsCategory
		{
			get
			{
				if (bizNewsCategory == null)
				{
					bizNewsCategory = new BizNewsCategory();
				}
				return bizNewsCategory;
			}
		}

		private BizPictureGroup _BizPictureGroup;
		private BizPictureGroup BizPictureGroup
		{
			get
			{
				if (_BizPictureGroup == null)
					_BizPictureGroup = new BizPictureGroup();
				return _BizPictureGroup;
			}
		}

		private BizNews _BizNews;
		private BizNews BizNews
		{
			get
			{
				if (_BizNews == null)
					_BizNews = new BizNews();
				return _BizNews;
			}
		}

		private BizPictureGroupXTag _BizPictureGroupXTag;
		private BizPictureGroupXTag BizPictureGroupXTag
		{
			get
			{
				if (_BizPictureGroupXTag == null)
					_BizPictureGroupXTag = new BizPictureGroupXTag();
				return _BizPictureGroupXTag;
			}
		}


		private BizNewsXTag _BizNewsXTag;
		private BizNewsXTag BizNewsXTag
		{
			get
			{
				if (_BizNewsXTag == null)
					_BizNewsXTag = new BizNewsXTag();
				return _BizNewsXTag;
			}
		}



		public bool NeedLoadRelational { get; set; }

		private EnumSystemCategory CurrentCategory { get; set; }

		public FrontFilterAttribute(EnumSystemCategory currentCategory)
		{
			this.CurrentCategory = currentCategory;
		}

		public override void OnActionExecuted(ActionExecutedContext filterContext)
		{
			ViewDataDictionary ViewData = filterContext.Controller.ViewData;
				switch (CurrentCategory)
				{
					case EnumSystemCategory.图片:
						ViewData["Categories"] = BizPictureCategory.List();
						break;
					case EnumSystemCategory.音乐:
						ViewData["Categories"] = BizMusicCategory.List();
						break;
					case EnumSystemCategory.视频:
						ViewData["Categories"] = BizVideoCategory.List();
						break;
					case EnumSystemCategory.新闻:
						ViewData["Categories"] = BizNewsCategory.List();
						break;
				}
		}
	}
}